package org.biubiu0002.baiblog.core.controller;

import org.biubiu0002.baiblog.common.utils.PageUtils;
import org.biubiu0002.baiblog.common.utils.R;
import org.biubiu0002.baiblog.core.model.entity.RichTextEntity;
import org.biubiu0002.baiblog.core.service.RichTextService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;



/**
 * 富文本内容表
 *
 * @author biubiu0002
 * @email 1007918011@qq.com
 * @date 2022-05-06 00:50:37
 */
@RestController
@RequestMapping("/richtext")
public class RichTextController {
    @Autowired
    private RichTextService richTextService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    //@RequiresPermissions("core:richtext:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = richTextService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    //@RequiresPermissions("core:richtext:info")
    public R info(@PathVariable("id") Long id){
		RichTextEntity richText = richTextService.getById(id);

        return R.ok().put("richText", richText);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    //@RequiresPermissions("core:richtext:save")
    public R save(@RequestBody RichTextEntity richText){
		richTextService.save(richText);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    //@RequiresPermissions("core:richtext:update")
    public R update(@RequestBody RichTextEntity richText){
		richTextService.updateById(richText);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    //@RequiresPermissions("core:richtext:delete")
    public R delete(@RequestBody Long[] ids){
		richTextService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
